{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Install [PyL7VP](https://pypi.org/project/pyl7vp)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "%pip install pyl7vp"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cBCn5mQ0m6ec"
      },
      "source": [
        "## Data"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "vemF0Scim3M6"
      },
      "outputs": [],
      "source": [
        "import pandas as pd\n",
        "\n",
        "df = pd.DataFrame(\n",
        "  {'longitude': [105.005, 104.602, 103.665, 105.275],\n",
        "   'latitude': [32.349, 32.067, 31.29, 32.416],\n",
        "   'mag': [5.2, 3.0, 6.0, 2.0]\n",
        "  })"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7G_-MgoBneqq"
      },
      "source": [
        "## Add dataset"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "5AUyaxmonZhQ",
        "outputId": "6010e84a-286e-40a6-f559-488fac6758ca"
      },
      "outputs": [],
      "source": [
        "from pyl7vp import L7VP\n",
        "\n",
        "l7vp_map = L7VP(height = 600)\n",
        "\n",
        "\n",
        "# Add dataset to map\n",
        "l7vp_map.add_dataset({\"id\": \"my_dataset\", \"type\": 'local', \"data\": df})"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "uK11oa2LZr5H"
      },
      "source": [
        "## Display map"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 621
        },
        "id": "GbBSE-aAZyS4",
        "outputId": "d4431caf-1975-49f7-b087-0aa206fd0c52"
      },
      "outputs": [],
      "source": [
        "# Set config\n",
        "l7vp_map.set_config({\n",
        "  \"map\": {\n",
        "    \"type\": \"Gaode\",\n",
        "    \"config\": {\n",
        "            \"zoom\": 7,\n",
        "            \"center\": [104.615357, 32.068745],\n",
        "            \"style\": 'dark',\n",
        "        },\n",
        "  },\n",
        "})\n",
        "\n",
        "# print datasets and config\n",
        "l7vp_map.datasets\n",
        "l7vp_map.config\n",
        "\n",
        "# Display map\n",
        "l7vp_map.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "-EXcbq6jY7om"
      },
      "source": [
        "## Customize Map"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LcdzQZp8Kpg7"
      },
      "source": [
        "![](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*pAh4TZBM4-0AAAAAAAAAAAAADmJ7AQ/original)\n",
        "\n",
        "\n",
        "Add layers, filters and popup, More in [Config Map Widget](https://www.yuque.com/antv/l7vp/pyl7vp-user-guide#LQzPy)."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "M5oSBsDHZ_ti"
      },
      "source": [
        "## Save to HTML File"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "id": "eYWGcysKaC1M",
        "outputId": "56bcbf70-d14f-40a7-c630-9d5d69760221"
      },
      "outputs": [],
      "source": [
        "# save to html file\n",
        "l7vp_map.save_to_html(\"map.html\")"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.6.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
